<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <title>公司信息批量添加</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <link href="${pageContext.request.contextPath}/assets/css/bs3/dpl.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/assets/css/page-min.css" rel="stylesheet" type="text/css" />   <!-- 下面的样式，仅是为了显示代码，而不应该在项目中使用-->
   <link href="${pageContext.request.contextPath}/assets/css/prettify.css" rel="stylesheet" type="text/css" />
   <style type="text/css">
    code {
      padding: 0px 4px;
      color: #d14;
      background-color: #f7f7f9;
      border: 1px solid #e1e1e8;
    }
   </style>
 </head>
<body>
    <div class="container">
    <div id="grid"></div>
    <p>
      <button id="btnSave" class="button button-primary">批量提交</button>
    </p>
      <div id="content" class="hide">
      <form id="J_Form" class="form-horizontal">
        <div class="row">
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司名称：</label>
            <div class="controls">
              <input name="cname" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label"><s>*</s>公司规模：</label>
            <div class="controls">
              <input name="ccount" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司地址：</label>
            <div class="controls">
              <input name="caddress" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9 ">
            <label class="control-label"><s>*</s>优惠政策：</label>
            <div class="controls">
              <input  type="text"  name="clabourcost" data-rules="{required:true}"/>
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司编号：</label>
            <div class="controls">
              <input name="cno" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司标签：</label>
            <div class="controls">
              <input name="remark"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
            <label class="control-label">最低薪资：</label>
            <div class="controls">
              <input name="csalaryl"  type="text" data-rules="{required:true}" class="control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">最高薪资：</label>
            <div class="controls">
              <input name="csalaryh"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">发薪日期：</label>
            <div class="controls">
              <input name="cpaydate"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
           <div class="control-group span9">
            <label class="control-label"><s>*</s>薪资结构：</label>
            <div class="controls" >
             <input name="cpaydetail"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">薪资发放：</label>
            <div class="controls">
              <input name="cpayexplain"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">伙食：</label>
            <div class="controls">
              <input name="cmeals"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
         </div> 
         <div class="row">
          <div class="control-group span9">
            <label class="control-label"><s>*</s>住宿：</label>
            <div class="controls">
              <input name="chousing"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label">公司班车：</label>
            <div class="controls">
              <input name="ctraffic"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
            <label class="control-label">工作培训：</label>
            <div class="controls">
              <input name="ctrain"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label">工时说明：</label>
            <div class="controls">
              <input name="cworktime"  type="text"  class="input-normal control-text">
            </div>
          </div>
        <div class="control-group span9">
            <label class="control-label">工作内容：</label>
            <div class="controls">
              <input name="cworkenvironment"  type="text"  class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
              <label class="control-label"><s>*</s>签订合同：</label>
              <div class="controls">
                <input name="ccontract" data-rules="{required:true}" type="text">
              </div>
           </div>
           <div class="control-group span9">
            <label class="control-label">五险福利：</label>
            <div class="controls">
              <input name="cinsurance"  type="text"  class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label"><s>*</s>公司图标：</label>
            <div class="controls">
              <input name="cphoto"  type="text"  class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
            <label class="control-label">公司介绍：</label>
            <div class="controls">
              <input name="cinformation" style="width:200px;" type="text"  class="input-normal control-text">
            </div>
          </div>
          
        </div>
      </form>
    </div>
  </div>
  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/jquery-1.8.1.min.js"></script>
  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/bui-min.js"></script>

  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/config-min.js"></script>
   <script type="text/javascript">
    BUI.use('common/page');
  </script>
<script type="text/javascript">
  BUI.use(['bui/grid','bui/data'],function (Grid,Data) {

    var columns = [{title : 'cid',dataIndex :'cid',width:10,visible:false},
                   {title : '公司名称',dataIndex :'cname',width:40},
                   {title : '公司地点',dataIndex :'caddress',width:40},
                   {title : '公司规模',dataIndex :'ccount',width:50},
                   {title : '保底薪资',dataIndex :'csalaryl',width:50},
                   {title : '最高薪资',dataIndex :'csalaryh',width:50},
                   {title : '优惠政策',dataIndex :'clabourcost',width:60},
                   {title : '公司标签',dataIndex :'remark',width:60},
                   {title : '发薪日',dataIndex :'cpaydate',width:60},
                   {title : '薪资结构',dataIndex :'cpaydetail',width:60},
                   {title : '伙食',dataIndex :'cmeals',width:60},
                   {title : '住宿',dataIndex :'chousing',width:60},
                   {title : '公司班车',dataIndex :'ctrafffic',width:60},
                   {title : '上班工时',dataIndex :'cworktime',width:60},
                   {title : '工作环境',dataIndex :'cworkenvironment',width:60},
                   {title : '入职培训',dataIndex :'ctrain',width:60},
                   {title : '公司编号',dataIndex :'cno',width:60},
                   {title : '公司合同',dataIndex :'ccontract',width:60},
                   {title : '薪资说明',dataIndex :'cpayexplain',width:60},
                   {title : '五险福利',dataIndex :'cinsurance',width:60},
                   {title : '公司图标',dataIndex :'cphoto',width:60},
                   {title : '公司介绍',dataIndex :'cinformation',width:60}
          ],
      //默认的数据
      data = [
        /* {id:'1',username:'武汉第一初级中学',enter:'1999-09-01',type: 'zou',outter:'2002-07-01',memo:'表现优异，多次评为三好学生'},
        {id:'2',username:'武汉第一高级中学',enter:'2002-09-01',type: 'zou',outter:'2005-07-01',memo:'表现优异，多次评为三好学生'} */
      ],
      store = new Data.Store({
        data:data
      }),
      editing = new Grid.Plugins.DialogEditing({
        contentId : 'content',
        triggerCls : 'btn-edit',
        eidtor : {
            focusable : false,
            triggerSelected:true
          }
      }),
      grid = new Grid.Grid({
        render : '#grid',
        columns : columns,
        loadMask:true,//加载数据时显示屏蔽层
        forceFit : true,//标签元素宽度自适应
        width : 2000,
        forceFit : true,
        store : store,
        plugins : [Grid.Plugins.CheckSelection,editing],
        tbar:{
          items : [{
            btnCls : 'button button-small',
            text : '<i class="icon-plus"></i>添加',
            listeners : {
              'click' : addFunction
            }
          },
          {
            btnCls : 'button button-small',
            text : '<i class="icon-remove"></i>删除',
            listeners : {
              'click' : delFunction
            }
          }]
        }

      });
    grid.render();

    function addFunction(){
      var newData = {cname :'请输入公司名称'};
      editing.add(newData); //添加记录后，直接编辑
    }

    function delFunction(){
      var selections = grid.getSelection();
      store.remove(selections);
    }
    //var logEl = $('#log');
    $('#btnSave').on('click',function(){
      var records = store.getResult();
      var companys=BUI.JSON.stringify(records);
      $.ajax({
          contentType:'application/json; charset=utf-8',//防止乱码
          dataType : 'json',
          traditional:true,
          url : '${pageContext.request.contextPath}/companyWeb/addCompanyInfoWeb.do',
          data : {companys:companys},
          success : function(data){
            if(data=="1"){ //添加成功
            	BUI.Message.Alert('添加成功！');
            	window.location.href='${pageContext.request.contextPath}/jsps/company/companyListAdd.jsp';
            }else{ //添加失败
              BUI.Message.Alert(data);
            }
          }
      });
      //alert(users);
     // var url='${pageContext.request.contextPath}/companyWeb/addCompanyInfoWeb.do';
      //var post={data:companys};
     // $.post(url,post);
      //logEl.text(BUI.JSON.stringify(records));
    });
  });
</script>
</body>
</html>